|
legup-4.0
|
InstCombiner - The -instcombine pass. More...
#include <InstCombine.h>
Inheritance diagram for llvm::InstCombiner:Public Types | |
| typedef IRBuilder< true, TargetFolder, InstCombineIRInserter > | BuilderTy |
Static Public Member Functions | |
| static const PassInfo * | lookupPassInfo (const void *TI) |
| static const PassInfo * | lookupPassInfo (StringRef Arg) |
| static Pass * | createPass (AnalysisID ID) |
Data Fields | |
| InstCombineWorklist | Worklist |
| Worklist - All of the instructions that need to be simplified. More... | |
| BuilderTy * | Builder |
Static Public Attributes | |
| static char | ID = 0 |
Protected Member Functions | |
| bool | skipOptnoneFunction (const Function &F) const |
Private Attributes | |
| const DataLayout * | DL |
| TargetLibraryInfo * | TLI |
| bool | MadeIRChange |
| LibCallSimplifier * | Simplifier |
| bool | MinimizeSize |
InstCombiner - The -instcombine pass.
Definition at line 86 of file InstCombine.h.
Builder - This is an IRBuilder that automatically inserts new instructions into the worklist when they are created.
Definition at line 101 of file InstCombine.h.
|
inline |
Definition at line 105 of file InstCombine.h.
|
overridevirtualinherited |
Find appropriate Function Pass Manager or Call Graph Pass Manager in the PM Stack and add self into that manager.
Reimplemented from llvm::Pass.
Definition at line 1865 of file LegacyPassManager.cpp.
| Instruction * InstCombiner::commonCastTransforms | ( | CastInst & | CI | ) |
Implement the transforms common to all CastInst visitors.
Definition at line 294 of file InstCombineCasts.cpp.
| Instruction* llvm::InstCombiner::commonDivTransforms | ( | BinaryOperator & | I | ) |
| Instruction * InstCombiner::commonIDivTransforms | ( | BinaryOperator & | I | ) |
Common integer divide transforms.
This function implements the transforms common to both integer division instructions (udiv and sdiv). It is called by the visitors to those integer division instructions.
Definition at line 713 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::commonIRemTransforms | ( | BinaryOperator & | I | ) |
Common integer remainder transforms.
This function implements the transforms common to both integer remainder instructions (urem and srem). It is called by the visitors to those integer remainder instructions.
Definition at line 1194 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::commonPointerCastTransforms | ( | CastInst & | CI | ) |
Implement the transforms for cast of pointer (bitcast/ptrtoint)
Definition at line 1431 of file InstCombineCasts.cpp.
| Instruction* llvm::InstCombiner::commonRemTransforms | ( | BinaryOperator & | I | ) |
| Instruction * InstCombiner::commonShiftTransforms | ( | BinaryOperator & | I | ) |
Definition at line 24 of file InstCombineShifts.cpp.
|
inline |
Definition at line 318 of file InstCombine.h.
|
inline |
Definition at line 327 of file InstCombine.h.
|
staticinherited |
Definition at line 195 of file Pass.cpp.
|
overridevirtualinherited |
createPrinterPass - Get a function printer pass.
Implements llvm::Pass.
Definition at line 134 of file Pass.cpp.
Descale - Return a value X such that Val = X * Scale, or null if none. If the multiplication is known not to overflow then NoSignedWrap is set.
Definition at line 940 of file InstructionCombining.cpp.
|
inlinevirtualinherited |
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes have run.
Reimplemented in llvm::FPPassManager, llvm::legacy::FunctionPassManagerImpl, llvm::NVPTXAsmPrinter, llvm::MachineModuleInfo, llvm::AsmPrinter, legup::MinimizeBitwidth, legup::SwOnly, legup::LegupPass, and legup::LiveVariableAnalysis.
|
inlinevirtualinherited |
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run.
Reimplemented in llvm::FPPassManager, llvm::legacy::FunctionPassManagerImpl, llvm::NVPTXAsmPrinter, llvm::MachineModuleInfo, llvm::AsmPrinter, legup::MinimizeBitwidth, legup::MemProf, legup::SwOnly, legup::LegupPass, llvm::MachineFunctionAnalysis, legup::LegUp, legup::LegUpTrackBB, legup::LiveVariableAnalysis, legup::LegUpWatch, and legup::PostLTO.
| bool InstCombiner::DoOneIteration | ( | Function & | F, |
| unsigned | ItNum | ||
| ) |
Definition at line 2638 of file InstructionCombining.cpp.
|
inherited |
Definition at line 116 of file Pass.cpp.
|
virtualinherited |
Reimplemented in llvm::FPPassManager, llvm::LPPassManager, and llvm::RGPassManager.
Definition at line 53 of file Pass.cpp.
Definition at line 631 of file InstructionCombining.cpp.
Definition at line 612 of file InstructionCombining.cpp.
Definition at line 98 of file InstructionCombining.cpp.
|
inline |
Definition at line 301 of file InstCombine.h.
Definition at line 744 of file InstCombineVectorOps.cpp.
EvaluateInDifferentType - Given an expression that CanEvaluateTruncated or CanEvaluateSExtd returns true for, actually insert the code to evaluate the expression.
Definition at line 163 of file InstCombineCasts.cpp.
|
private |
FindElementAtOffset - Given a pointer type and a constant offset, determine whether or not there is a sequence of GEP indices into the pointed type that will land us at the specified offset. If so, fill them into NewIndices and return the resultant element type, otherwise return null.
Definition at line 865 of file InstructionCombining.cpp.
FoldAndOfFCmps - Optimize (fcmp)&(fcmp). NOTE: Unlike the rest of instcombine, this returns a Value which should already be inserted into the function.
Definition at line 1027 of file InstCombineAndOrXor.cpp.
FoldAndOfICmps - Fold (icmp)&(icmp) if possible.
Definition at line 791 of file InstCombineAndOrXor.cpp.
| Instruction * InstCombiner::FoldCmpLoadFromIndexedGlobal | ( | GetElementPtrInst * | GEP, |
| GlobalVariable * | GV, | ||
| CmpInst & | ICI, | ||
| ConstantInt * | AndCst = nullptr |
||
| ) |
FoldCmpLoadFromIndexedGlobal - Called we see this pattern: cmp pred (load (gep GV, ...)), cmpcst where GV is a global variable with a constant initializer. Try to simplify this into some simple computation that does not need the load. For example we can optimize "icmp eq (load (gep "foo", 0, i)), 0" into "icmp eq i, 3".
If AndCst is non-null, then the loaded value is masked with that constant before doing the comparison. This handles cases like "A[i]&4 == 0".
TrueRangeEnd/FalseRangeEnd - In conjunction with First*Element, these define a state machine that triggers for ranges of values that the index is true or false for. This triggers on things like "abbbbc"[i] == 'b'. This is -2 when undefined, -3 when overdefined, and otherwise the last index in the range (inclusive). We use -2 for undefined here because we use relative comparisons and don't want 0-1 to match -1.
Definition at line 220 of file InstCombineCompares.cpp.
| Instruction * InstCombiner::FoldFCmp_IntToFP_Cst | ( | FCmpInst & | I, |
| Instruction * | LHSI, | ||
| Constant * | RHSC | ||
| ) |
FoldFCmp_IntToFP_Cst - Fold fcmp ([us]itofp x, cst) if possible.
Definition at line 3291 of file InstCombineCompares.cpp.
| Value * InstCombiner::foldFMulConst | ( | Instruction * | FMulOrDiv, |
| Constant * | C, | ||
| Instruction * | InsertBefore | ||
| ) |
foldFMulConst() is a helper routine of InstCombiner::visitFMul(). The input FMulOrDiv is a FMul/FDiv with one and only one operand being a constant (i.e. isFMulOrFDivWithConstant(FMulOrDiv) == true). This function is to simplify "FMulOrDiv * C" and returns the resulting expression. Note that this function could return NULL in case the constants cannot be folded into a normal floating-point.
Definition at line 385 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::FoldGEPICmp | ( | GEPOperator * | GEPLHS, |
| Value * | RHS, | ||
| ICmpInst::Predicate | Cond, | ||
| Instruction & | I | ||
| ) |
FoldGEPICmp - Fold comparisons between a GEP instruction and something else. At this point we know that the GEP is on the LHS of the comparison.
Definition at line 604 of file InstCombineCompares.cpp.
| Instruction * InstCombiner::FoldICmpAddOpCst | ( | Instruction & | ICI, |
| Value * | X, | ||
| ConstantInt * | CI, | ||
| ICmpInst::Predicate | Pred | ||
| ) |
FoldICmpAddOpCst - Fold "icmp pred (X+CI), X".
Definition at line 740 of file InstCombineCompares.cpp.
| Instruction * InstCombiner::FoldICmpDivCst | ( | ICmpInst & | ICI, |
| BinaryOperator * | DivI, | ||
| ConstantInt * | DivRHS | ||
| ) |
FoldICmpDivCst - Fold "icmp pred, ([su]div X, DivRHS), CmpRHS" where DivRHS and CmpRHS are both known to be integer constants.
If the division is known to be exact, then there is no remainder from the divide, so the covered range size is unit, otherwise it is the divisor.
Definition at line 804 of file InstCombineCompares.cpp.
| Instruction * InstCombiner::FoldICmpShrCst | ( | ICmpInst & | ICI, |
| BinaryOperator * | DivI, | ||
| ConstantInt * | DivRHS | ||
| ) |
FoldICmpShrCst - Handle "icmp(([al]shr X, cst1), cst2)".
Definition at line 961 of file InstCombineCompares.cpp.
|
private |
FoldLogicalPlusAnd - This is part of an expression (LHS +/- RHS) & Mask, where isSub determines whether the operator is a sub. If we can fold one of the following xforms:
((A & N) +/- B) & Mask -> (A +/- B) & Mask iff N&Mask == Mask ((A | N) +/- B) & Mask -> (A +/- B) & Mask iff N&Mask == 0 ((A ^ N) +/- B) & Mask -> (A +/- B) & Mask iff N&Mask == 0
return (A +/- B).
Definition at line 332 of file InstCombineAndOrXor.cpp.
|
private |
FoldOpIntoPhi - Given a binary operator, cast instruction, or select which has a PHI node as operand #0, see if we can fold the instruction into the PHI (which is only possible if all operands to the PHI are constants).
Definition at line 724 of file InstructionCombining.cpp.
|
private |
Definition at line 687 of file InstructionCombining.cpp.
FoldOrOfFCmps - Optimize (fcmp)|(fcmp). NOTE: Unlike the rest of instcombine, this returns a Value which should already be inserted into the function.
Definition at line 1823 of file InstCombineAndOrXor.cpp.
FoldOrOfICmps - Fold (icmp)|(icmp) if possible.
Definition at line 1557 of file InstCombineAndOrXor.cpp.
| Instruction * InstCombiner::FoldOrWithConstants | ( | BinaryOperator & | I, |
| Value * | Op, | ||
| Value * | A, | ||
| Value * | B, | ||
| Value * | C | ||
| ) |
FoldOrWithConstants - This helper function folds:
((A | B) & C1) | (B & C2)
into:
(A & C1) | B
when the XOR of the two constants is "all ones" (-1).
Definition at line 1889 of file InstCombineAndOrXor.cpp.
|
private |
FoldPHIArgBinOpIntoPHI - If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the add's all have a single use, turn this into a phi and a single binop.
Definition at line 26 of file InstCombinePHI.cpp.
|
private |
Definition at line 132 of file InstCombinePHI.cpp.
|
private |
Definition at line 287 of file InstCombinePHI.cpp.
|
private |
FoldPHIArgOpIntoPHI - If all operands to a PHI node are the same "unary" operator and they all are only used by the PHI, PHI together their inputs, and do the operation once, to the result of the PHI.
Definition at line 391 of file InstCombinePHI.cpp.
| Instruction * InstCombiner::FoldSelectIntoOp | ( | SelectInst & | SI, |
| Value * | TrueVal, | ||
| Value * | FalseVal | ||
| ) |
FoldSelectIntoOp - Try fold the select into one of the operands to facilitate further optimization.
Definition at line 235 of file InstCombineSelect.cpp.
| Instruction * InstCombiner::FoldSelectOpOp | ( | SelectInst & | SI, |
| Instruction * | TI, | ||
| Instruction * | FI | ||
| ) |
FoldSelectOpOp - Here we have (select c, TI, FI), and we know that TI and FI have the same opcode and only one use each. Try to simplify this.
Definition at line 148 of file InstCombineSelect.cpp.
| Instruction * InstCombiner::FoldShiftByConstant | ( | Value * | Op0, |
| Constant * | Op1, | ||
| BinaryOperator & | I | ||
| ) |
Definition at line 314 of file InstCombineShifts.cpp.
| Instruction * InstCombiner::FoldSPFofSPF | ( | Instruction * | Inner, |
| SelectPatternFlavor | SPF1, | ||
| Value * | A, | ||
| Value * | B, | ||
| Instruction & | Outer, | ||
| SelectPatternFlavor | SPF2, | ||
| Value * | C | ||
| ) |
FoldSPFofSPF - We have an SPF (e.g. a min or max) of an SPF of the form: SPF2(SPF1(A, B), C)
Definition at line 683 of file InstCombineSelect.cpp.
|
virtualinherited |
getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through multiple inheritance. If needed, it should override this to adjust the this pointer as needed for the specified pass info.
Reimplemented in llvm::LibCallAliasAnalysis, and llvm::objcarc::ObjCARCAliasAnalysis.
|
inherited |
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function.
Definition at line 199 of file PassAnalysisSupport.h.
|
inherited |
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function.
Definition at line 228 of file PassAnalysisSupport.h.
|
inherited |
Definition at line 205 of file PassAnalysisSupport.h.
|
inherited |
Definition at line 235 of file PassAnalysisSupport.h.
|
inherited |
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information that might be around, for example to update it. This is different than getAnalysis in that it can fail (if the analysis results haven't been computed), so should only be used if you can handle the case when the analysis is not available. This method is often used by transformation APIs to update analysis results for a pass automatically as the transform is performed.
Definition at line 179 of file PassAnalysisSupport.h.
|
overridevirtual |
Reimplemented from llvm::Pass.
Definition at line 92 of file InstructionCombining.cpp.
|
virtualinherited |
Reimplemented in llvm::ImmutablePass.
|
virtualinherited |
|
inline |
Definition at line 117 of file InstCombine.h.
|
inlineinherited |
getPassID - Return the PassID number that corresponds to this pass.
|
virtualinherited |
getPassName - Return a nice clean name for a pass. This usually implemented in terms of the name that is registered by one of the Registration templates, but can be overloaded directly.
Reimplemented in llvm::FPPassManager, llvm::NVPTXAsmPrinter, llvm::LPPassManager, llvm::RGPassManager, llvm::MipsAsmPrinter, llvm::AMDGPUAsmPrinter, llvm::JumpInstrTables, llvm::ARMAsmPrinter, legup::LegupPass, llvm::DebugIR, llvm::MipsModuleDAGToDAGISel, llvm::JumpInstrTableInfo, llvm::NVPTXLowerAggrCopies, llvm::NVPTXAllocaHoisting, llvm::MachineFunctionAnalysis, llvm::MipsDAGToDAGISel, llvm::Mips16HardFloat, llvm::MipsOs16, llvm::SystemZAsmPrinter, llvm::X86AsmPrinter, and llvm::HexagonAsmPrinter.
Definition at line 61 of file Pass.cpp.
|
overridevirtualinherited |
Return what kind of Pass Manager can manage this pass.
Reimplemented from llvm::Pass.
Definition at line 139 of file Pass.cpp.
|
inlineinherited |
|
inline |
Definition at line 119 of file InstCombine.h.
|
inline |
Definition at line 259 of file InstCombine.h.
|
inline |
Definition at line 271 of file InstCombine.h.
|
private |
Emit a computation of: (V >= Lo && V < Hi) if Inside is true, otherwise (V < Lo || V >= Hi). In practice, we emit the more efficient (V-Lo) <u Hi-Lo. This method expects that Lo <= Hi. isSigned indicates whether to treat the V, Lo and HI as signed or not. IB is the location to insert new instructions.
Definition at line 263 of file InstCombineAndOrXor.cpp.
Definition at line 187 of file Pass.cpp.
Definition at line 191 of file Pass.cpp.
|
inline |
Definition at line 323 of file InstCombine.h.
|
private |
MatchBSwap - Given an OR instruction, check to see if this is a bswap idiom. If so, insert the new bswap intrinsic and return it.
ByteValues - For each byte of the result, we keep track of which value defines each byte.
Definition at line 1501 of file InstCombineAndOrXor.cpp.
|
inherited |
mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable, but works if you just have an AnalysisID. This obviously cannot give you a properly typed instance of the class if you don't have the class name available (use getAnalysisIfAvailable if you do), but it can tell you if you need to preserve the pass at least.
Definition at line 48 of file Pass.cpp.
|
private |
Definition at line 123 of file InstCombineAndOrXor.cpp.
Optimize pointer differences into the same array into a size. Consider: &A[10] - &A[0]: we should compile this to "10". LHS/RHS are the pointer operands to the ptrtoint instructions for the LHS/RHS of the subtract.
Definition at line 1384 of file InstCombineAddSub.cpp.
|
virtualinherited |
Check if available pass managers are suitable for this pass or not.
Reimplemented in llvm::RegionPass, and llvm::LoopPass.
|
virtualinherited |
print - Print out the internal state of the pass. This is called by Analyze to print out the contents of an analysis. Otherwise it is not necessary to implement this method. Beware that the module pointer MAY be null. This automatically forwards to a virtual function that does not provide the Module* in case the analysis doesn't need it it can just be ignored.
Reimplemented in llvm::DependenceAnalysis, llvm::ScalarEvolution, llvm::RegionInfoPass, llvm::LoopInfo, llvm::CallGraphWrapperPass, llvm::LiveIntervals, llvm::DominanceFrontier, llvm::DominatorTreeWrapperPass, llvm::VirtRegMap, llvm::IVUsers, llvm::MachineDominatorTree, llvm::MachineRegionInfoPass, llvm::LiveStacks, llvm::PostDominatorTree, llvm::MachinePostDominatorTree, llvm::IntervalPartition, llvm::BranchProbabilityInfo, llvm::BlockFrequencyInfo, and llvm::FindUsedTypes.
Definition at line 111 of file Pass.cpp.
|
private |
PromoteCastOfAllocation - If we find a cast of an allocation instruction, try to eliminate the cast by moving the type information into the alloc.
Definition at line 81 of file InstCombineCasts.cpp.
|
virtualinherited |
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memory when it is no longer needed. The default behavior of passes is to hold onto memory for the entire duration of their lifetime (which is the entire compile time). For pipelined passes, this is not a big deal because that memory gets recycled every time the pass is invoked on another program unit. For IP passes, it is more important to free memory when it is unused.
Optionally implement this function to release pass memory when it is no longer used.
Reimplemented in llvm::DependenceAnalysis, llvm::ScalarEvolution, llvm::RegionInfoPass, llvm::LoopInfo, llvm::CallGraphWrapperPass, llvm::SlotIndexes, llvm::MemoryDependenceAnalysis, llvm::LiveIntervals, llvm::LiveVariables, llvm::DominanceFrontier, llvm::DominatorTreeWrapperPass, llvm::MachineDominatorTree, llvm::SpillPlacement, llvm::IVUsers, llvm::MachineLoopInfo, llvm::MachineRegionInfoPass, llvm::MachineDominanceFrontier, llvm::IntervalPartition, llvm::LiveStacks, llvm::PostDominatorTree, llvm::MachineTraceMetrics, llvm::LazyValueInfo, llvm::LiveDebugVariables, llvm::LiveRegMatrix, llvm::MachineFunctionAnalysis, llvm::MachineBlockFrequencyInfo, and llvm::BlockFrequencyInfo.
|
inline |
Definition at line 282 of file InstCombine.h.
|
overridevirtual |
Builder - This is an IRBuilder that automatically inserts new instructions into the worklist when they are created.
Implements llvm::FunctionPass.
Definition at line 2828 of file InstructionCombining.cpp.
|
private |
Definition at line 115 of file InstCombineVectorOps.cpp.
|
inherited |
ShouldChangeType - Return true if it is desirable to convert a computation from 'From' to 'To'. We don't want to convert from a legal to an illegal type for example, or from a smaller to a larger illegal type.
Definition at line 105 of file InstructionCombining.cpp.
|
private |
ShouldOptimizeCast - Return true if the cast from "V to Ty" actually results in any code being generated and is interesting to optimize out. If the cast can be eliminated by some other simple transformation, we prefer to do the simplification first.
Definition at line 273 of file InstCombineCasts.cpp.
|
private |
SimplifyAssociativeOrCommutative - This performs a few simplifications for operators which are associative or commutative.
SimplifyAssociativeOrCommutative - This performs a few simplifications for operators which are associative or commutative:
Definition at line 203 of file InstructionCombining.cpp.
|
private |
SimplifyDemandedBits - This form of SimplifyDemandedBits simplifies the specified instruction operand if possible, updating it in place. It returns true if it made any change and false otherwise.
Definition at line 70 of file InstCombineSimplifyDemanded.cpp.
|
private |
SimplifyDemandedInstructionBits - Inst is an integer instruction that SimplifyDemandedBits knows about. See if the instruction has any properties that allow us to simplify its operands.
Definition at line 54 of file InstCombineSimplifyDemanded.cpp.
|
private |
SimplifyDemandedUseBits - Attempts to replace V with a simpler value based on the demanded bits.
SimplifyDemandedUseBits - This function attempts to replace V with a simpler value based on the demanded bits. When this function is called, it is known that only the bits set in DemandedMask of the result of V are ever used downstream. Consequently, depending on the mask and V, it may be possible to replace V with a constant or one of its operands. In such cases, this function does the replacement and returns true. In all other cases, it returns false after analyzing the expression and setting KnownOne and known to be one in the expression. KnownZero contains all the bits that are known to be zero in the expression. These are provided to potentially allow the caller (which might recursively be SimplifyDemandedBits itself) to simplify the expression. KnownOne and KnownZero always follow the invariant that KnownOne & KnownZero == 0. That is, a bit can't be both 1 and 0. Note that the bits in KnownOne and KnownZero may only be accurate for those bits set in DemandedMask. Note also that the bitwidth of V, DemandedMask, KnownZero and KnownOne must all be the same.
This returns null if it did not change anything and it permits no simplification. This returns V itself if it did some simplification of V's operands based on the information about what bits are demanded. This returns some other non-null value if it found out that V is equal to another value in the context where the specified bits are demanded, but not for all users.
Definition at line 102 of file InstCombineSimplifyDemanded.cpp.
|
private |
SimplifyDemandedVectorElts - The specified value produces a vector with any number of elements. DemandedElts contains the set of elements that are actually used by the caller. This method analyzes which elements of the operand are undef and returns that information in UndefElts.
If the information about demanded elements can be used to simplify the operation, the operation is simplified, then the resultant value is returned. This returns null if no change was made.
Definition at line 917 of file InstCombineSimplifyDemanded.cpp.
| bool InstCombiner::SimplifyDivRemOfSelect | ( | BinaryOperator & | I | ) |
SimplifyDivRemOfSelect - Try to fold a divide or remainder of a select instruction.
Definition at line 640 of file InstCombineMulDivRem.cpp.
|
private |
Definition at line 156 of file InstCombineCalls.cpp.
|
private |
Definition at line 60 of file InstCombineCalls.cpp.
|
private |
Helper routine of SimplifyDemandedUseBits. It tries to simplify demanded bit for "r1 = shr x, c1; r2 = shl r1, c2" instruction sequence.
Helper routine of SimplifyDemandedUseBits. It tries to simplify "E1 = (X lsr C1) << C2", where the C1 and C2 are constant, into "E2 = X << (C2 - C1)" or "E2 = X >> (C1 - C2)", depending on the sign of "C2-C1".
Suppose E1 and E2 are generally different in bits S={bm, bm+1, ..., bn}, without considering the specific value X is holding. This transformation is legal iff one of following conditions is hold: 1) All the bit in S are 0, in this case E1 == E2. 2) We don't care those bits in S, per the input DemandedMask. 3) Combination of 1) and 2). Some bits in S are 0, and we don't care the rest bits.
Currently we only test condition 2).
As with SimplifyDemandedUseBits, it returns NULL if the simplification was not successful.
Definition at line 845 of file InstCombineSimplifyDemanded.cpp.
|
private |
SimplifyStoreAtEndOfBlock - Turn things like: if () { *P = v1; } else { *P = v2 } into a phi node with a store in the successor.
Simplify things like: *P = v1; if () { *P = v2; } into a phi node with a store in the successor.
Definition at line 726 of file InstCombineLoadStoreAlloca.cpp.
|
private |
SimplifyUsingDistributiveLaws - This tries to simplify binary operations which some other binary operation distributes over either by factorizing out common terms (eg "(A*B)+(A*C)" -> "A*(B+C)") or expanding out if this results in simplifications (eg: "A & (B | C) -> (A&B) | (A&C)" if this is a win). Returns the simplified value, or null if it didn't simplify.
Definition at line 525 of file InstructionCombining.cpp.
|
private |
Makes transformation of binary operation specific for vector types.
| Inst | Binary operator to transform. |
Definition at line 1202 of file InstructionCombining.cpp.
skipOptnoneFunction - This function has Attribute::OptimizeNone and most transformation passes should skip it.
Definition at line 143 of file Pass.cpp.
| Instruction * InstCombiner::SliceUpIllegalIntegerPHI | ( | PHINode & | FirstPhi | ) |
SliceUpIllegalIntegerPHI - This is an integer PHI and we know that it has an illegal type: see if it is only used by trunc or trunc(lshr) operations. If so, we split the PHI into the various pieces being extracted. This sort of thing is introduced when SROA promotes an aggregate to large integer values.
TODO: The user of the trunc may be an bitcast to float/double/vector or an inttoptr. We should produce new PHIs in the right type.
Definition at line 618 of file InstCombinePHI.cpp.
|
private |
Definition at line 1487 of file InstCombineCalls.cpp.
|
private |
Definition at line 1227 of file InstCombineCalls.cpp.
|
private |
transformSExtICmp - Transform (sext icmp) to bitwise / integer operations in order to eliminate the icmp.
Definition at line 894 of file InstCombineCasts.cpp.
|
private |
transformZExtICmp - Transform (zext icmp) to bitwise / integer operations in order to eliminate the icmp.
Definition at line 513 of file InstCombineCasts.cpp.
|
private |
Definition at line 1037 of file InstCombineCalls.cpp.
|
virtualinherited |
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis information.
Reimplemented in llvm::ScalarEvolution, llvm::RegionInfoPass, llvm::LoopInfo, llvm::DominatorTreeWrapperPass, llvm::MachineRegionInfoPass, and llvm::MachineTraceMetrics.
|
inlineinherited |
Definition at line 90 of file InstVisitor.h.
|
inlineinherited |
Definition at line 97 of file InstVisitor.h.
|
inlineinherited |
Definition at line 101 of file InstVisitor.h.
|
inlineinherited |
Definition at line 105 of file InstVisitor.h.
|
inlineinherited |
Definition at line 111 of file InstVisitor.h.
|
inlineinherited |
Definition at line 112 of file InstVisitor.h.
|
inlineinherited |
Definition at line 113 of file InstVisitor.h.
|
inlineinherited |
Definition at line 114 of file InstVisitor.h.
|
inlineinherited |
Definition at line 118 of file InstVisitor.h.
| Instruction * InstCombiner::visitAdd | ( | BinaryOperator & | I | ) |
Definition at line 1020 of file InstCombineAddSub.cpp.
| Instruction * InstCombiner::visitAddrSpaceCast | ( | AddrSpaceCastInst & | CI | ) |
Definition at line 1911 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 194 of file InstVisitor.h.
| Instruction * InstCombiner::visitAllocaInst | ( | AllocaInst & | AI | ) |
Definition at line 165 of file InstCombineLoadStoreAlloca.cpp.
| Instruction * InstCombiner::visitAllocSite | ( | Instruction & | FI | ) |
Definition at line 1800 of file InstructionCombining.cpp.
| Instruction * InstCombiner::visitAnd | ( | BinaryOperator & | I | ) |
Definition at line 1105 of file InstCombineAndOrXor.cpp.
| Instruction * InstCombiner::visitAShr | ( | BinaryOperator & | I | ) |
Definition at line 772 of file InstCombineShifts.cpp.
|
inlineinherited |
Definition at line 177 of file InstVisitor.h.
|
inlineinherited |
Definition at line 178 of file InstVisitor.h.
|
inlineinherited |
Definition at line 143 of file InstVisitor.h.
|
inlineinherited |
Definition at line 232 of file InstVisitor.h.
| Instruction * InstCombiner::visitBitCast | ( | BitCastInst & | CI | ) |
Definition at line 1783 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 193 of file InstVisitor.h.
| Instruction * InstCombiner::visitBranchInst | ( | BranchInst & | BI | ) |
Definition at line 1927 of file InstructionCombining.cpp.
| Instruction * InstCombiner::visitCallInst | ( | CallInst & | CI | ) |
visitCallInst - CallInst simplification. This mostly only handles folding of intrinsic instructions. For normal calls, it allows visitCallSite to do the heavy lifting.
Definition at line 203 of file InstCombineCalls.cpp.
|
private |
Definition at line 1126 of file InstCombineCalls.cpp.
|
inlineinherited |
Definition at line 231 of file InstVisitor.h.
|
inlineinherited |
Definition at line 233 of file InstVisitor.h.
|
inlineinherited |
Definition at line 205 of file InstVisitor.h.
|
inlineinherited |
Definition at line 207 of file InstVisitor.h.
|
inlineinherited |
Definition at line 206 of file InstVisitor.h.
| Instruction * InstCombiner::visitExtractElementInst | ( | ExtractElementInst & | EI | ) |
Definition at line 179 of file InstCombineVectorOps.cpp.
| Instruction * InstCombiner::visitExtractValueInst | ( | ExtractValueInst & | EV | ) |
Definition at line 1999 of file InstructionCombining.cpp.
| Instruction * InstCombiner::visitFAdd | ( | BinaryOperator & | I | ) |
Definition at line 1272 of file InstCombineAddSub.cpp.
| Instruction * InstCombiner::visitFCmpInst | ( | FCmpInst & | I | ) |
Orders the operands of the compare so that they are listed from most complex to least complex. This puts constants before unary operators, before binary operators.
Definition at line 3492 of file InstCombineCompares.cpp.
| Instruction * InstCombiner::visitFDiv | ( | BinaryOperator & | I | ) |
Definition at line 1061 of file InstCombineMulDivRem.cpp.
|
inlineinherited |
Definition at line 179 of file InstVisitor.h.
| Instruction * InstCombiner::visitFMul | ( | BinaryOperator & | I | ) |
Definition at line 433 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::visitFPExt | ( | CastInst & | CI | ) |
Definition at line 1354 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 186 of file InstVisitor.h.
| Instruction * InstCombiner::visitFPToSI | ( | FPToSIInst & | FI | ) |
Definition at line 1378 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 188 of file InstVisitor.h.
| Instruction * InstCombiner::visitFPToUI | ( | FPToUIInst & | FI | ) |
Definition at line 1358 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 187 of file InstVisitor.h.
| Instruction * InstCombiner::visitFPTrunc | ( | FPTruncInst & | CI | ) |
Definition at line 1171 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 185 of file InstVisitor.h.
| Instruction * InstCombiner::visitFree | ( | CallInst & | FI | ) |
Definition at line 1896 of file InstructionCombining.cpp.
| Instruction * InstCombiner::visitFRem | ( | BinaryOperator & | I | ) |
Definition at line 1335 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::visitFSub | ( | BinaryOperator & | I | ) |
Definition at line 1601 of file InstCombineAddSub.cpp.
|
inlineinherited |
Definition at line 142 of file InstVisitor.h.
| Instruction * InstCombiner::visitGetElementPtrInst | ( | GetElementPtrInst & | GEP | ) |
See if we can simplify: X = bitcast A* to B* Y = gep X, <...constant indices...> into a gep of the original struct. This is important for SROA and alias analysis of unions. If "A" is also a bitcast, wait for A/X to be merged.
Definition at line 1284 of file InstructionCombining.cpp.
| Instruction * InstCombiner::visitICmpInst | ( | ICmpInst & | I | ) |
Orders the operands of the compare so that they are listed from most complex to least complex. This puts constants before unary operators, before binary operators.
Definition at line 2327 of file InstCombineCompares.cpp.
| Instruction * InstCombiner::visitICmpInstWithCastAndCast | ( | ICmpInst & | ICI | ) |
visitICmpInstWithCastAndCast - Handle icmp (cast x to y), (cast/cst). We only handle extending casts so far.
Definition at line 1790 of file InstCombineCompares.cpp.
| Instruction * InstCombiner::visitICmpInstWithInstAndIntCst | ( | ICmpInst & | ICI, |
| Instruction * | LHSI, | ||
| ConstantInt * | RHS | ||
| ) |
visitICmpInstWithInstAndIntCst - Handle "icmp (instr, intcst)".
Definition at line 1050 of file InstCombineCompares.cpp.
|
inlineinherited |
Definition at line 169 of file InstVisitor.h.
| Instruction * InstCombiner::visitInsertElementInst | ( | InsertElementInst & | IE | ) |
Definition at line 528 of file InstCombineVectorOps.cpp.
| Instruction * InstCombiner::visitInsertValueInst | ( | InsertValueInst & | I | ) |
Try to find redundant insertvalue instructions, like the following ones: %0 = insertvalue { i8, i32 } undef, i8 x, 0 %1 = insertvalue { i8, i32 } %0, i8 y, 0 Here the second instruction inserts values at the same indices, as the first one, making the first one redundant. It should be transformed to: %0 = insertvalue { i8, i32 } undef, i8 y, 0
Definition at line 500 of file InstCombineVectorOps.cpp.
|
inline |
Definition at line 224 of file InstCombine.h.
|
inlineinherited |
Definition at line 216 of file InstVisitor.h.
| Instruction * InstCombiner::visitIntToPtr | ( | IntToPtrInst & | CI | ) |
Definition at line 1406 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 192 of file InstVisitor.h.
| Instruction * InstCombiner::visitInvokeInst | ( | InvokeInst & | II | ) |
Definition at line 1004 of file InstCombineCalls.cpp.
| Instruction * InstCombiner::visitLandingPadInst | ( | LandingPadInst & | LI | ) |
Definition at line 2193 of file InstructionCombining.cpp.
| Instruction * InstCombiner::visitLoadInst | ( | LoadInst & | LI | ) |
Definition at line 360 of file InstCombineLoadStoreAlloca.cpp.
| Instruction * InstCombiner::visitLShr | ( | BinaryOperator & | I | ) |
Definition at line 729 of file InstCombineShifts.cpp.
|
inlineinherited |
Definition at line 209 of file InstVisitor.h.
|
inlineinherited |
Definition at line 212 of file InstVisitor.h.
|
inlineinherited |
Definition at line 210 of file InstVisitor.h.
|
inlineinherited |
Definition at line 208 of file InstVisitor.h.
|
inlineinherited |
Definition at line 211 of file InstVisitor.h.
|
inlineinherited |
Definition at line 141 of file InstVisitor.h.
| Instruction * InstCombiner::visitMul | ( | BinaryOperator & | I | ) |
i1 mul -> i1 and.
Definition at line 119 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::visitOr | ( | BinaryOperator & | I | ) |
Definition at line 1909 of file InstCombineAndOrXor.cpp.
| Instruction * InstCombiner::visitPHINode | ( | PHINode & | PN | ) |
Definition at line 790 of file InstCombinePHI.cpp.
| Instruction * InstCombiner::visitPtrToInt | ( | PtrToIntInst & | CI | ) |
Definition at line 1490 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 191 of file InstVisitor.h.
|
inlineinherited |
Definition at line 170 of file InstVisitor.h.
|
inlineinherited |
Definition at line 166 of file InstVisitor.h.
| Instruction * InstCombiner::visitSDiv | ( | BinaryOperator & | I | ) |
Definition at line 968 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::visitSelectInst | ( | SelectInst & | SI | ) |
Definition at line 823 of file InstCombineSelect.cpp.
| Instruction * InstCombiner::visitSelectInstWithICmp | ( | SelectInst & | SI, |
| ICmpInst * | ICI | ||
| ) |
visitSelectInstWithICmp - Visit a SelectInst that has an ICmpInst as its first operand.
Definition at line 469 of file InstCombineSelect.cpp.
| Instruction * InstCombiner::visitSExt | ( | SExtInst & | CI | ) |
Definition at line 1041 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 184 of file InstVisitor.h.
| Instruction * InstCombiner::visitShl | ( | BinaryOperator & | I | ) |
Definition at line 688 of file InstCombineShifts.cpp.
| Instruction * InstCombiner::visitShuffleVectorInst | ( | ShuffleVectorInst & | SVI | ) |
Definition at line 856 of file InstCombineVectorOps.cpp.
| Instruction * InstCombiner::visitSIToFP | ( | CastInst & | CI | ) |
Definition at line 1402 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 190 of file InstVisitor.h.
| Instruction * InstCombiner::visitSRem | ( | BinaryOperator & | I | ) |
Definition at line 1261 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::visitStoreInst | ( | StoreInst & | SI | ) |
Definition at line 596 of file InstCombineLoadStoreAlloca.cpp.
| Instruction * InstCombiner::visitSub | ( | BinaryOperator & | I | ) |
Definition at line 1451 of file InstCombineAddSub.cpp.
| Instruction * InstCombiner::visitSwitchInst | ( | SwitchInst & | SI | ) |
Definition at line 1975 of file InstructionCombining.cpp.
|
inlineinherited |
Definition at line 234 of file InstVisitor.h.
| Instruction * InstCombiner::visitTrunc | ( | TruncInst & | CI | ) |
Definition at line 439 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 182 of file InstVisitor.h.
| Instruction * InstCombiner::visitUDiv | ( | BinaryOperator & | I | ) |
Definition at line 906 of file InstCombineMulDivRem.cpp.
| Instruction * InstCombiner::visitUIToFP | ( | CastInst & | CI | ) |
Definition at line 1398 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 189 of file InstVisitor.h.
|
inlineinherited |
Definition at line 235 of file InstVisitor.h.
|
inlineinherited |
Definition at line 171 of file InstVisitor.h.
| Instruction * InstCombiner::visitURem | ( | BinaryOperator & | I | ) |
Definition at line 1226 of file InstCombineMulDivRem.cpp.
|
inlineinherited |
Definition at line 196 of file InstVisitor.h.
|
inlineinherited |
Definition at line 215 of file InstVisitor.h.
|
inlineinherited |
Definition at line 214 of file InstVisitor.h.
|
inlineinherited |
Definition at line 213 of file InstVisitor.h.
| Instruction * InstCombiner::visitXor | ( | BinaryOperator & | I | ) |
Definition at line 2221 of file InstCombineAndOrXor.cpp.
| Instruction * InstCombiner::visitZExt | ( | ZExtInst & | CI | ) |
Definition at line 760 of file InstCombineCasts.cpp.
|
inlineinherited |
Definition at line 183 of file InstVisitor.h.
WillNotOverflowSignedAdd - Return true if we can prove that: (sext (add LHS, RHS)) === (add (sext LHS), (sext RHS)) This basically requires proving that the add in the original type would not overflow to change the sign bit or have a carry out. TODO: Handle this for Vectors.
Definition at line 898 of file InstCombineAddSub.cpp.
WillNotOverflowUnsignedAdd - Return true if we can prove that: (zext (add LHS, RHS)) === (add (zext LHS), (zext RHS))
Definition at line 946 of file InstCombineAddSub.cpp.
| BuilderTy* llvm::InstCombiner::Builder |
Definition at line 102 of file InstCombine.h.
|
private |
Definition at line 89 of file InstCombine.h.
|
static |
Definition at line 104 of file InstCombine.h.
|
private |
Definition at line 91 of file InstCombine.h.
|
private |
Definition at line 93 of file InstCombine.h.
|
private |
Definition at line 92 of file InstCombine.h.
|
private |
Definition at line 90 of file InstCombine.h.
| InstCombineWorklist llvm::InstCombiner::Worklist |
Worklist - All of the instructions that need to be simplified.
Definition at line 97 of file InstCombine.h.